# -*- coding:utf-8 -*-
import requests
from retrying import retry


@retry(stop_max_attempt_number=3)  # 最大尝试次数
def get_data(url):
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36'
    }
    print(111)
    response = requests.get(url, headers=headers, timeout=3)  # timeout限制时间3秒
    return response


def data(url):
    respones = get_data(url)
    return respones


if __name__ == '__main__':
    url = 'http://www.google.com'
    data(url)
